package org.roulette.servlet;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import org.roulette.controller.TimerJob;
import org.roulette.model.Game;
import org.roulette.model.Player;
import org.roulette.model.Table;

public class ServletContext implements ServletContextListener {
	ServletContext context;

	public void contextInitialized(ServletContextEvent contextEvent) {
		System.out.println("Creating context!");
		Game game = Game.getInstance();
		for (int i = 0; i < 6; i++) {
			Table table = game.addTableToGame();
			for (int z = 0; z < 3; z++) {
				Player player = new Player("Table" + table.getId()
						+ "Player" + z, "pass");
				Game.addPlayer(player);
				table.addPlayerToTable(player);
			}
		}
		new TimerJob();
		Game.betOnTable("Table1Player0", 1+"", 10);
		Game.betOnTable("Table1Player1", 2+"", 11);
	}

	public void contextDestroyed(ServletContextEvent contextEvent) {
		System.out.println("Destroying context!");
	}
}